﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NetFrameworkExtensions.PresentationLayer
{
  public static class WindowManagerExtensions
  {
    public static Guid Show(this IWindowManager manager, object control, IWindowContext context = null)
    {
      if (manager == null) throw new ArgumentNullException("manager");
      return manager.Show(() => control, context);
    }

    public static Guid? GetIdentifier(this IWindowManager manager, object control)
    {
      if (manager == null) throw new ArgumentNullException("manager");
      var context = manager.GetWindowContext(control);
      if (context == null) return null;
      return context.WindowGuid;
    }

    public static Guid? GetParentIdentifier(this IWindowManager manager, object control)
    {
      if (manager == null) throw new ArgumentNullException("manager");
      var context = manager.GetWindowContext(control);
      if (context == null) return null;
      return context.ParentGuid;
    }
  }
}
